package com.netlisten;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.pcap4j.core.PcapAddress;
import org.pcap4j.core.PcapNetworkInterface;
import org.pcap4j.core.Pcaps;

public class Main {
    private static final Logger logger = LogManager.getLogger(Main.class);
    
    public static void main(String[] args) {
        logger.info("程序启动");
        try {
        	System.out.println("获取网络接口");
        	for (PcapNetworkInterface ni : Pcaps.findAllDevs()) {
                System.out.println(ni.getName());
                for (PcapAddress addr : ni.getAddresses()) {
                    System.out.println("-->" + addr.getAddress());
                }
            }
		} catch (Exception e) {
			
		}
        

        // 初始化配置
        Config config = new Config();
        
        // 启动数据包嗅探器
        PacketSniffer packetSniffer = new PacketSniffer(config.TARGET_HOST, config.TARGET_PORT, config.SOURCE_HOST, config.SOURCE_PORT);
        packetSniffer.startSniffing();
        
        logger.info("所有监听器已启动");
    }
}